package config

import (
	"fmt"

	"databasex"

	"gorm.io/driver/postgres"
	"gorm.io/gorm"
)

func GetGormDB() *gorm.DB {
	open, err := gorm.Open(postgres.Open(PostgresDSN), &gorm.Config{})
	if err != nil {
		panic(err)
	}
	return open
}

var PostgresHost = databasex.Host

// "clickhouse://default@127.0.0.1/default?client_info_product[my-app]=0.1")
var PostgresDSN = fmt.Sprintf("user=%v password=%v host=%v port=%v dbname=%v sslmode=disable TimeZone=Asia/Shanghai",
	PostgresUser, PostgresPassword, PostgresHost, PostgresPort, PostgresDatabase)

const (
	PostgresUser     = "postgres"
	PostgresPassword = "root"
	PostgresPort     = 5432
	PostgresDatabase = "casbin"
)
